/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.asportoonline.tags;

import java.io.IOException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.util.List;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

/**
 *
 * @author fe
 */
public class ElencoLocalitaTag extends SimpleTagSupport {
    private List<String> localita;

    public List<String> getLocalita() {
        return localita;
    }

    public void setLocalita(List<String> localita) {
        this.localita = localita;
    }
    
    @Override
    public void doTag() throws JspException {
        JspWriter out = getJspContext().getOut();
        List<String> lista = getLocalita();
        String loc;
        
        try {
            out.print("<option value=\"none\">Scegli localit&agrave;...</option>");
            out.flush();
            
            if(lista!=null) {
                for(int i=0; i<lista.size(); i++) {
                    loc = lista.get(i);

                    out.print("<option value=\""+loc+"\">"+loc+"</option>");
                }            
            }
            out.flush();
            
        } catch(IOException ex) {
            throw new JspException("Error in ElencoLocalitaTag tag", ex);
        }
    }
    
}
